<template>
  <div class="error-page">
    <div class="error-content">
      <div class="error-illustration">
        <svg
          width="200"
          height="200"
          viewBox="0 0 200 200"
          fill="none"
          xmlns="http://www.w3.org/2000/svg"
        >
          <circle cx="100" cy="100" r="80" fill="#f3f4f6" />
          <path
            d="M60 80h80v40H60z"
            fill="#9ca3af"
          />
          <circle cx="80" cy="60" r="5" fill="#374151" />
          <circle cx="120" cy="60" r="5" fill="#374151" />
          <path
            d="M75 140c10-10 40-10 50 0"
            stroke="#374151"
            stroke-width="3"
            stroke-linecap="round"
          />
        </svg>
      </div>
      
      <div class="error-info">
        <h1 class="error-code">404</h1>
        <h2 class="error-title">页面不存在</h2>
        <p class="error-description">
          抱歉，您访问的页面不存在或已被删除。
          <br />
          请检查URL是否正确，或返回首页继续浏览。
        </p>
        
        <div class="error-actions">
          <el-button type="primary" @click="goHome">
            <el-icon><House /></el-icon>
            返回首页
          </el-button>
          
          <el-button @click="goBack">
            <el-icon><Back /></el-icon>
            返回上页
          </el-button>
          
          <el-button link @click="refresh">
            <el-icon><Refresh /></el-icon>
            刷新页面
          </el-button>
        </div>
      </div>
    </div>
    
    <div class="error-footer">
      <p>如果问题持续存在，请联系系统管理员</p>
    </div>
  </div>
</template>

<script>
import { defineComponent } from 'vue'
import { useRouter } from 'vue-router'
import { House, Back, Refresh } from '@element-plus/icons-vue'

export default defineComponent({
  name: 'NotFound',
  components: {
    House,
    Back,
    Refresh
  },
  setup() {
    const router = useRouter()
    
    // 返回首页
    const goHome = () => {
      router.push('/')
    }
    
    // 返回上一页
    const goBack = () => {
      if (window.history.length > 1) {
        router.go(-1)
      } else {
        router.push('/')
      }
    }
    
    // 刷新页面
    const refresh = () => {
      window.location.reload()
    }
    
    return {
      goHome,
      goBack,
      refresh
    }
  }
})
</script>

<style lang="scss" scoped>
.error-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  position: relative;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><defs><radialGradient id="a" cx="50%" cy="50%"><stop offset="0%" stop-color="rgba(255,255,255,.1)"/><stop offset="100%" stop-color="rgba(255,255,255,0)"/></radialGradient></defs><circle fill="url(%23a)" cx="10" cy="10" r="10"/><circle fill="url(%23a)" cx="30" cy="10" r="10"/><circle fill="url(%23a)" cx="50" cy="10" r="10"/><circle fill="url(%23a)" cx="70" cy="10" r="10"/><circle fill="url(%23a)" cx="90" cy="10" r="10"/></svg>') repeat;
    opacity: 0.1;
  }
}

.error-content {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 48px;
  max-width: 600px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 1;
  
  @include respond-to(xs) {
    padding: 24px;
  }
}

.error-illustration {
  margin-bottom: 32px;
  
  svg {
    max-width: 100%;
    height: auto;
    
    @include respond-to(xs) {
      width: 150px;
      height: 150px;
    }
  }
}

.error-info {
  .error-code {
    font-size: 6rem;
    font-weight: bold;
    color: var(--primary-color);
    margin: 0 0 16px 0;
    line-height: 1;
    
    @include respond-to(xs) {
      font-size: 4rem;
    }
  }
  
  .error-title {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-color-primary);
    margin: 0 0 16px 0;
    
    @include respond-to(xs) {
      font-size: 1.5rem;
    }
  }
  
  .error-description {
    font-size: 1rem;
    color: var(--text-color-secondary);
    line-height: 1.6;
    margin: 0 0 32px 0;
    
    @include respond-to(xs) {
      font-size: 0.9rem;
    }
  }
}

.error-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  
  .el-button {
    min-width: 120px;
    
    @include respond-to(xs) {
      min-width: 100px;
      font-size: 14px;
    }
  }
}

.error-footer {
  position: absolute;
  bottom: 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  z-index: 1;
  
  @include respond-to(xs) {
    position: static;
    margin-top: 24px;
    color: rgba(255, 255, 255, 0.9);
  }
}

// 移动端优化
@include respond-to(xs) {
  .error-page {
    padding: 16px;
    min-height: 100vh;
    justify-content: flex-start;
    padding-top: 60px;
  }
  
  .error-content {
    border-radius: 12px;
  }
}
</style>
